package vip.yuange.gsyzm.utils;

import java.awt.image.BufferedImage;
import java.io.IOException;

public class GSYZMOCRUtils {
	
	public static String getGSYZMText(String gsyzmColor,String gsyzmBase64) {
		String yzm="";
		try {  
			if (gsyzmBase64.startsWith("data:image/png;base64,")) {  
				gsyzmBase64 = gsyzmBase64.replace("data:image/png;base64,", "");  
			}  
			BufferedImage image = PublicUtils.base64ToBufferedImage(gsyzmBase64);  
			if (image != null) {
				String color=PublicUtils.gsyzmColor(gsyzmColor);
				int tolerance=255;
				try {
					BufferedImage a=PublicUtils.keepColorAndMakeOthersWhite(image,color,tolerance);
						yzm=YZMOCRUtils.ORC(a);
				} catch (IOException e) {
					e.printStackTrace();
				}
			} else {  
				System.out.println("Failed to read image from Base64 string.");  
			}  
		} catch (IOException e) {  
			e.printStackTrace();  
		}  
		return yzm;
	}

}
